var app = getApp();
var WxParse = require('../../lib/wxParse/wxParse.js');
var util = require('../../utils/util.js');
var api = require('../../config/api.js');

Page({
  data: {
    id: 0,
    time:30 * 60 * 60 * 1000,
    supply: {},
    imgs:[]
  },
  onLoad: function(options) {
    // 页面初始化 options为页面跳转所带来的参数
    var that = this;
    that.setData({
      id: options.id
    });

    util.request(api.SupplyDetail, {
      id: that.data.id
    }).then(function(res) {
      if (res.errno === 0) {
        let supply = res.data.supply;
        supply.publishDt = util.formatTime2(new Date(supply.publishDt),"Y/M/D");
        let herbListImage = supply.herbListImage;
        let imgs = '';
        if(herbListImage){
          imgs = herbListImage.split(',')
        }
        
        that.setData({
          supply: supply,
          imgs:imgs
        });
      }
    });
  },
  onReady: function() {

  },
  onShow: function() {
    // 页面显示
  },
  onHide: function() {
    // 页面隐藏

  },
  onUnload: function() {
    // 页面关闭

  }
})